// pages/index/index.js
Page({
  data: {
    allStudents: [
      {name: '冯晨晨', lineNum: 1},
      {name: '蔡钧霖', lineNum: 2},
      {name: '高芷歆', lineNum: 3},
      {name: '胡茗浩', lineNum: 4},
      {name: '何知熠', lineNum: 5},
      {name: '黄泳锡', lineNum: 6},
      {name: '兰晞月', lineNum: 7},
      {name: '孙晟峻', lineNum: 8},
      {name: '徐一', lineNum: 9},
      {name: '叶展亦', lineNum: 10},
      {name: '杨烁菡', lineNum: 11},
      {name: '姚世棋', lineNum: 12},
      {name: '卜静怡', lineNum: 13},
      {name: '奉靖涵', lineNum: 14},
      {name: '王译可', lineNum: 15},
      {name: '胡益', lineNum: 16},
      {name: '荣晚姝', lineNum: 17},
      {name: '李佳颖', lineNum: 18},
      {name: '刘淇锐', lineNum: 19},
      {name: '欧阳明月', lineNum: 20},
      {name: '吴易宸', lineNum: 21},
      {name: '钱梦莹', lineNum: 22},
      {name: '周佳涵', lineNum: 23},
      {name: '陈平实', lineNum: 24},
      {name: '郑明菡', lineNum: 25},
      {name: '刘忻与', lineNum: 26},
      {name: '李翔昇-转学', lineNum: 27},
      {name: '邹沁依', lineNum: 28},
      {name: '王锴源', lineNum: 29},
      {name: '周苏沁', lineNum: 30},
      {name: '张天易', lineNum: 31},
      {name: '陈语晨', lineNum: 32},
      {name: '谢子航', lineNum: 33},
      {name: '杨荣婉瑜', lineNum: 34},
      {name: '陈墨轩', lineNum: 35},
      {name: '唐羽慧', lineNum: 36},
      {name: '徐梓麒', lineNum: 37},
      {name: '张梓煜', lineNum: 38},
      {name: '王禹乔', lineNum: 39},
      {name: '易子芮', lineNum: 40},
      {name: '黄梓恩', lineNum: 41},
      {name: '尹梓安', lineNum: 42},
      {name: '刘依依', lineNum: 43},
      {name: '孙逸辰', lineNum: 44},
      {name: '马皓晨', lineNum: 45},
      {name: '饶梓杰', lineNum: 46},
      {name: '郑逸宸', lineNum: 47},
      {name: '李瑞依', lineNum: 48},
      {name: '李子悅', lineNum: 49},
      {name: '张梓菡', lineNum: 50}
    ],
    jiedongStudents: '',
    notJiedongStudents: [],
    showResult: false
  },

  // 输入框内容变化时更新数据
  onJiedongStudentsChange(e) {
    this.setData({
      jiedongStudents: e.detail.value
    });
  },

  // 提交表单
  onSubmit() {
    const { jiedongStudents, allStudents } = this.data;
    
    if (!jiedongStudents.trim()) {
      wx.showToast({
        title: '请输入接龙学生名单',
        icon: 'none'
      });
      return;
    }
    
    // 处理接龙学生名单
    const jiedongList = jiedongStudents.split('\n').filter(name => name.trim());
    
    // 找出未参与接龙的学生
    const notJiedongStudents = allStudents.filter(student => 
      !jiedongList.some(jd => jd.includes(student.name))
    );
    
    // 更新页面数据
    this.setData({
      notJiedongStudents,
      showResult: true
    });
  },

  // 返回首页
  backToIndex() {
    this.setData({
      showResult: false,
      jiedongStudents: ''
    });
  }
});    